<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>默认HTML页面</title>
</head>

<body>
    <h2>人员列表</h2>
    <div id="person">
        <input type="text" v-model="searchText">
        <ul>
            <li v-for="person in filterPersonList" :key="person.idCardNumber">
                {{person.name}}-{{person.name}}-{{person.idCardNumber}}
            </li>
        </ul>
    </div>

</body>
<script src="../script/vue.js"></script>
<script>
    new Vue({
        el: "#person",
        data: {
            searchText: '',
            personList: [
                { 'name': '马冬梅', 'age': 18, 'idCardNumber': '360122199590945252' },
                { 'name': '周冬雨', 'age': 19, 'idCardNumber': '360122199590942462' },
                { 'name': '周杰伦', 'age': 20, 'idCardNumber': '360122199590945246' },
                { 'name': '周星星', 'age': 21, 'idCardNumber': '360122199590945476' },
                { 'name': '温兆伦', 'age': 21, 'idCardNumber': '360122199590944526' },
            ],
            filterPersonList: [

            ]
        },
        watch: {
            searchText: {
                immediate: true,
                handler(val) {
                    this.filterPersonList = this.personList.filter((item) => {
                        return item.name.indexOf(val) !== -1;
                    });
                }
            }
        }
    })
</script>

</html>